<%inherit file="base.html"/>
<%def name="head()">
<script src="/static/js/bootstrap-datepicker.js"></script>
<link rel="stylesheet" href="/static/js/datepicker.css"> 
<script>

function productCalc(){
    param = {
        'months': $("#months").val() || 0,
        'product_id':$("#product_id").val(),
        'old_expire':$("#old_expire").val(),
        'giftdays':$("#giftdays").val(),
        '_xsrf': '${handler.xsrf_token}'
    }
    $.post("/admin/account/opencalc", param, function (ev) {
        console.log(ev);
        if(ev.code==0){
            console.log(ev.data);
            $("#fee_value").val(ev.data.fee_value);
            $("#expire_date").val(ev.data.expire_date);
        }
        if(ev.data.policy == 0){
            $("#months").parent().parent().show();
        }else{
            $("#months").val(0);
            $("#months").parent().parent().hide();
        }
    }, "json");
}

//页面初始化
$(document).ready(function (){
    //$("#expire_date").datepicker();
    productCalc();
    $('#product_id').change(function() {
        productCalc();
    });
    $('#months').blur(function() {
        productCalc();
    }); 
    $('#giftdays').blur(function() {
        productCalc();
    });       
});
</script>

</%def>
<%def name="body()">
<section class="content">

    <div class="box box-default">
        <div class="box-header">
            <i class="fa fa-user"></i>
            <h3 class="box-title">${form.title}</h3>
            <div class="bar pull-right"><a href="javascript:history.go(-1);">返回</a></div>
        </div>
        <div class="box-body">
            <div class="container">

            % if msg:
            <div class="alert alert-warning">${msg}</div>
            % endif
        <table class="table table-hover">
                <thead>
                    <tr>
                        <th colspan="6"> 用户账号信息</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>用户账号</td>
                        <td>${user.account_number}</td>
                        <td>资费名称</td>
                        <td>${user.product_name}</td>
                        <td>用户状态</td>
                        <td>${{1:u"正常",2:u"停机",3:u"销户",4:u"到期",6:u"未激活"}[user.status]}</td>                 
                    </tr>
                    <tr>
                        <td>过期时间</td>
                        <td>${user.expire_date}</td>
                        <td>余额</td>
                        <td>${utils.fen2yuan(user.balance)}</td>
                        <td>剩余时长</td>
                        <td>${utils.sec2hour(user.time_length)}小时</td>
                    </tr>      
                    <tr>
                        <td>剩余流量</td>
                        <td>${utils.kb2mb(user.flow_length)}MB</td>
                        <td>并发数</td>
                        <td>${user.user_concur_number}</td>
                        <td>绑定MAC</td>
                        <td>${{0:u"否", 1:u"是"}[user.bind_mac]}</td>                        
                    </tr>   
                    <tr>
                        <td>绑定VLAN</td>
                        <td>${{0:u"否", 1:u"是"}[user.bind_vlan]}</td>
                        <td>VLANID1/VLANID2</td>
                        <td>${user.vlan_id1}/${user.vlan_id2}</td>
                        <td>MAC地址</td>
                        <td>${user.mac_addr}</td>                        
                    </tr>   
                    <tr>
                        <td>IP地址</td>
                        <td>${user.ip_address}</td>
                        <td>安装地址</td>
                        <td>${user.install_address}</td>
                        <td>创建时间</td>
                        <td>${user.create_time}</td>                        
                    </tr>                                                                      
            </tbody>

        </table>
          <hr/>            
            <form class="form-horizontal form-well" role="form" action="${form.action}" method="post">
            ${xsrf_form_html()}
            ${form.render_css()}
            </form>
    </div>
</div>
</div>
    </section>
</%def>